package gspushmq.model;

public class ApiMessage extends Message{
	
	/**
	 * 哈希码值
	 */
	private volatile int hasCode = 1;
	
	@Override
	public int hashCode() {
		
		String requestId = super.getRequest_id();
		String accountId = super.getAccount_id();
		String apiUrl = super.getApi_url();
		String product_line = super.getProduct_line();
		
		int result = hasCode;
		if(result == 1){
			result = 31 * result + ((requestId == null) ? 0 : requestId.hashCode());
			result = 31 * result + ((accountId == null) ? 0 : accountId.hashCode());
			result = 31 * result + ((apiUrl == null) ? 0 : apiUrl.hashCode());
			result = 31 * result + ((product_line == null) ? 0 : product_line.hashCode());
			hasCode = result;
		}
		return result;
	}
	
	public String getMessageFlag(){
		String requestId = super.getRequest_id();
		String accountId = super.getAccount_id();
		String apiUrl = super.getApi_url();
		String product_line = super.getProduct_line();
		return "requestId=" + requestId + "|accountId=" + accountId+"|apiUrl=" + apiUrl + "|product_line=" + product_line;
	}
	
	@Override
	public boolean equals(Object obj) {
		
		if(obj == this){
			return true;
		}else if(obj == null){
			return false;
		}else if(!(obj instanceof ApiMessage)){
			return false;
		}
		ApiMessage mo = (ApiMessage)obj;
		return this.getMessageFlag().equals(mo.getMessageFlag());
	}
}
